<?php
class dangtin_model extends CI_Model
{
	var $account ;
	
	function __construct(){
        parent::__construct();
		
		$this->account = get_ses_login();
	}

	function get_all($num=30,$start=0)
	{
		$this->db->where('bl_active', 1);
		$this->db->where('member_id', $this->account['member_id']);
		$this->db->order_by('dt_create','desc') ;
		$query = $this->db->get('raovat', $num, $start);
		return $query->result();
	}
	
	function count_all()
	{
		$this->db->where('bl_active', 1);
		$this->db->where('member_id', $this->account['member_id']);
		$query = $this->db->get('raovat');
		return $query->num_rows();
	}
	
	function get_id($id)
	{
		$this->db->where('raovat_id', $id);
		$query = $this->db->get('raovat');
		return $query->row();
	}
	
	function save($data, $id=0)
	{
		if(!empty($id))
		{
			$this->db->where('raovat_id', $id);
			return $this->db->update('raovat', $data) ;
		}
		else
		{
			return $this->db->insert('raovat',$data);		
		}
	}
}
?>
